import { Component, OnInit, Inject, ChangeDetectionStrategy } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
import { NewTaskListComponent } from '../new-task-list/new-task-list.component';

@Component({
  selector: 'task-new-task',
  templateUrl: './new-task.component.html',
  styleUrls: ['./new-task.component.scss'],
  // 对于笨组件 所有的状态改变都是来自于输入属性 值边他才会变
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class NewTaskComponent implements OnInit {
  title = '';
  priorites = [
    {
      label: '紧急',
      value: 1
    }, {
      label: '重要',
      value: 2
    }, {
      label: '普通',
      value: 3
    },
  ];
  constructor(@Inject(MAT_DIALOG_DATA) private data, private dialogRef: MatDialogRef<NewTaskListComponent>) { }

  ngOnInit() {
    this.title = this.data.title;
    console.log(JSON.stringify(this.data.task));
  }
  onClick() {
    this.dialogRef.close(this.title);
  }
}
